using System;

namespace Gadgeteer.Interfaces.Sample.PhotoCamera.CameraApp
{
    public class BusyIndicator : IDisposable
    {
        private readonly BusyIndicationStack stack;

        public BusyIndicator(BusyIndicationStack stack)
        {
            this.stack = stack;
        }

        private void ClearFromStack()
        {
            stack.Remove(this);
        }

        #region dispose
        private bool disposed;
        protected virtual void Dispose(bool disposing)
        {
            if (disposed == false)
            {
                if (disposing)
                {
                    ClearFromStack();
                }

                disposed = true;
            }
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
        #endregion
    }
}
